<template>
  <el-row class="layout">
    <el-col :lg="16" :md="12" class="left">
      <div>
        <div class="title">后台管理</div>
        <div class="desc">欢迎使用优秀的后台管理系统...</div>
      </div>
    </el-col>
    <el-col :lg="8" :md="12" class="right">
      <h2 class="login">欢迎回来</h2>
      <div class="desc">
        <span class="line"></span>
        <span class="text-gray-300">帐号密码登录</span>
        <span class="line"></span>
      </div>
      <el-form :model="form" :rules="rules" ref="formRef" class="w-[250px]">
        <el-form-item prop="username">
          <el-input v-model="form.username" placeholder="请输入用户名">
            <template #prefix>
              <el-icon>
                <User />
              </el-icon>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input v-model="form.password" placeholder="请输入密码">
            <template #prefix>
              <el-icon>
                <Lock />
              </el-icon>
            </template>
          </el-input>
        </el-form-item>
        <el-form-item>
          <el-button round class="w-[250px]" type="warning" @click="onSubmit">登录</el-button>
        </el-form-item>
      </el-form>
    </el-col>
  </el-row>
</template>

<script setup lang="ts">
// import { User, Lock } from '@element-plus/icons-vue'

const form = reactive({
  username: '',
  password: '',
})

const rules = {
  username: [
    {
      required: true,
      message: '用户名不能为空',
      trigger: 'blur'
    }
  ],
  password: [
    {
      required: true,
      message: '密码不能为空',
      trigger: 'blur'
    }
  ]
}

const formRef = ref(null)
const onSubmit = () => {
  formRef.value.validate(valid => {
    if (valid) {
      console.log([...form])
    }
  })
}
</script>

<style scoped lang="scss">
.layout {
  @apply min-h-screen;
  .left {
    @apply flex items-center justify-center flex-col;
    background: $second_color;
    .title {
      @apply font-bold text-5xl text-light-50 mb-4;
    }
    .desc {
      @apply text-gray-200 text-sm tracking-2px;
    }
  }
  .right {
    @apply flex items-center justify-center flex-col;
    .login {
      @apply font-bold text-3xl text-gray-800;
    }
    .desc {
      @apply flex items-center justify-center my-5 space-x-2;
    }
    .line {
      @apply h-[1px] w-16 bg-gray-200;
    }
  }
}
</style>
